﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DataAccess.Classes;
using DataAccess;
using System.Collections.Generic;

public partial class Admin_CapNhatPhongTro : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        List<DiaDiem> list = DiaDiem.LayDanhSach();
        ddlDiaDiem.DataSource = list;
        ddlDiaDiem.DataTextField = "TenDiaDiem";
        ddlDiaDiem.DataValueField = "ID";
        ddlDiaDiem.DataBind();

        string id = Request.QueryString["cid"].ToString();
        PhongTro phong = PhongTro.Single(id);
        txtTen.Text = phong.Ten;
        txtThongTin.Text = phong.ThongTin;
        txtGiaPhong.Text = phong.GiaTien.ToString();
        txtHinh.Text = phong.HinhChinh;
    }
    protected void btnLuu_Click(object sender, EventArgs e)
    {
        string id = Request.QueryString["cid"].ToString();
        PhongTro phong = PhongTro.Single(id);
        phong.ID = Convert.ToInt32(ddlDiaDiem.SelectedValue.ToString());
        phong.Ten = txtTen.Text;
        phong.ThongTin = txtThongTin.Text;
        phong.HinhChinh = txtHinh.Text;
        phong.HinhDaiDien = txtHinh.Text;
        if (chkTinhTrang.Checked == true)
        {
            phong.TinhTrang = Convert.ToBoolean("True".ToString());
        }
        if (chkTinhTrang.Checked == false)
        {
            phong.TinhTrang = Convert.ToBoolean("False".ToString());
        }
        PhongTro.CapNhat(phong);
    }
}
